{% extends 'common/base.html' %}
{% import 'common/page.html' as pg %}
{% block css %}
    <style>
        .err {
            pointer-events: none;
        }
    </style>
{% endblock %}
{% block content %}
    <section class="content-header">
        <div>
            <ol class="breadcrumb">
                <li><a href="#"><i class="fa fa-dashboard"></i> 用户管理</a></li>
                <li class="active">消息通知</li>
            </ol>
        </div>
    </section>
    <section class="content" id="showcontent">
        <div class="row">
            <div class="col-md-12">
                <div class="box box-primary">
                    <div class="box-header">
                        <h3 class="box-title">消息列表</h3>
                        <div class="box-tools">
                            <div class="float-right" style="margin-right:5px;width: 200px">
                                <form action="" method="GET">
                                    <div class="input-group input-group-sm">
                                        <input type="text" class="form-control" name="keyword"
                                               placeholder="请输入内容" value="{{ keyword }}">
                                        <span class="input-group-btn">
                                             <button class="btn btn-default" type="submit"><i class="fa fa-search"></i></button>
                                        </span>
                                    </div>
                                </form>
                            </div>
                        </div>
                    </div>
                    <div class="box-body table-responsive no-padding">
                        <table class="table table-hover">
                            <tbody>
                            <tr>
                                <th>编号</th>
                                <th>发件人</th>
                                <th>是否已读</th>
                                <th>内容</th>
                                <th>时间</th>
                                <th>操作事项</th>
                            </tr>
                            {% for v in page_data.items %}
                                <tr>
                                    <td>{{ v.id }}</td>
                                    <td>{{ v.sender.username }}</td>
                                    {% if  v.is_read == 0 %}
                                        <td style="color: #ee0000">未读</td>
                                    {% else %}
                                        <td style="color: #00a157">已读</td>
                                    {% endif %}

                                    <td class="context" data-context="{{ v.context }}"></td>
                                    <td>{{ v.addtime }}</td>
                                    <td>
                                        <a id="star" href="{{ url_for('main.getMessageDetail',id = v.id) }}"
                                           class="label label-success">查看详情</a>&nbsp;
                                        <a id="star" href="{{ url_for('main.delMessage',id = v.id) }}"
                                           class="label label-danger" onclick="del()">删除</a>&nbsp;
                                    </td>
                                </tr>
                            {% endfor %}
                            </tbody>
                        </table>
                    </div>
                    <div class="box-footer clearfix">
                        {{ pg.page(page_data,'main.message',keyword) }}
                    </div>
                </div>
            </div>
        </div>
    </section>
{% endblock %}
{% block js %}
    <script>
        function del() {
            return confirm("确定删除该信息?");
        }

        $(function () {
            $('.context').each(function () {
                var self = $(this);
                self.html(self.data('context'));
            })
        })
    </script>
{% endblock %}